﻿
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    .form .formValue input.form-control {
        height: 34px;
        line-height: 34px;
    }

    .form-control {
        padding: 0px;
    }

    .autocomplete-suggestions {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        border: 1px solid #999;
        background: #FFF;
        cursor: default;
        overflow: auto;
        -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-no-suggestion {
        padding: 2px 5px;
    }

    .Table {
        width: 100%;
        margin: 0px;
        padding: 0px;
        border-collapse: collapse;
        border-width: 3px 1px 1px;
        table-layout: fixed;
    }
</style>
<script>
    var resultData;
    var workFlowId = $.request("keyValue");
    //var keyValue = $.request("keyValue");
    //var workFlowName = $.request("workFlowName");
    //var state = $.request("state");
    debugger 
    $(function () {
        initData();
    });

    function initData() {
        $.ajax({
            url: "/WorkFlowSetting/FlowManage/GetDetailItemsJson",
            dataType: "json",
            async: false,
            success: function (data) {
                resultData = data;

            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });

        InitControl();

        $.ajax({
            url: "/WorkFlowSetting/FlowManage/GetEditWorkFlowJson?keyValue=" + workFlowId,
            dataType: "json",
            async: false,
            success: function (data) {
                $("#F_WorkFlowName").val(data.F_WorkFlowName);
                $("#F_WorkFormId").val(data.F_WorkFormId);
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }

    function InitControl() {

        var F_WorkFormId = resultData.F_WorkFormId;
        for (var i = 0; i < F_WorkFormId.length; i++) {
            $("#F_WorkFormId").append("<option value='" + F_WorkFormId[i].F_ItemCode + "'>" + F_WorkFormId[i].F_ItemName + "</option>");
        }
    }

    function submitForm() {

        if (!$('#form1').formValid()) {
            return false;
        }

        //console.log($('#F_WorkFlowName').val());
        $.submitForm({
            url: "/WorkFlowSetting/FlowManage/SaveWorkFlow?keyValue=" + workFlowId,
            param: {
                'F_WorkFlowName': $('#F_WorkFlowName').val(),
                'F_WorkFormId': $('#F_WorkFormId').val()
            },
            success: function (result) {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
                //result = JSON.parse(result);
                //if (result.state == 1) {

                //} else {
                //    $.modalAlert(result.msg, "warning");
                //}

                //$.closeTab();
            }
        });
    }

</script>
<div id="ProjectsDetail">
    <form id="form1">
        <table class="form">
            <tr>
                <td colspan="6">
                    <table class="Table">
                        <tr>
                            <td class="formTitle">流程名称</td>
                            <td class="formValue">
                                <div class="input-group" style="width: 100%;">
                                    <input type="text" id="F_WorkFlowName" name="F_WorkFlowName required" class="form-control" placeholder="" />
                                </div>
                            </td>
                            <td class="formTitle">流程表单</td>
                            <td class="formValue">
                                <select id="F_WorkFormId" name="F_WorkFormId" class="form-control required"></select>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>
</div>
